pub mod test1 {
  use std::ops::{Deref, DerefMut};
  use std::sync::{Arc, Mutex};
  struct Son {
    value: Arc<Mutex<i32>>,
  }
  impl Son {
    pub fn println(&mut self) {
      let mut lock_ret = self.value.lock().expect("");
      let ret = lock_ret.deref_mut();
      *ret = 3;
      println!("{}", ret);
    }
  }
  struct Father {
    child: Arc<Son>,
    child2: Son,
  }
  impl Father {
    pub fn println(&mut self) {
      // self.child.deref().println();
      // self.child.println();
      self.child2.println();
    }
  }
}

pub mod test2 {
  use std::ops::{Deref, DerefMut};
  use std::sync::{Arc, Mutex};
  struct Son {
    value: Arc<Mutex<i32>>,
    value2: Arc<i32>,
  }
  impl Son {
    // pub const fn new()-> Son {
    //   Son {
    //     value: Arc::new(Mutex::new(1)),
    //     value2: Arc::new(2),
    //   }
    // }
    pub fn println_mut(&mut self) {
      let mut lock_ret = self.value.lock().expect("");
      let ret = lock_ret.deref_mut();
      *ret = 3;
      println!("{}", ret);
    }
    pub fn println(&self) {
      println!("{}", self.value2);
    }
  }
  struct Father {
    child: Arc<Mutex<Son>>,
  }
  impl Father {
    // pub const fn new()->Father {
    //    Father{
    //     child: Arc::new(Mutex::new(Son::new())),
    //   }
    // }
    pub fn println(&mut self) {
      let ret_lock = self.child.lock().expect("");
      ret_lock.deref().println();
      ret_lock.println(); // 隐式调用了`deref()`
      let mut ret_lock_mut = self.child.lock().expect("");
      ret_lock_mut.println_mut(); // 隐式调用了`deref_mut()`
      ret_lock_mut.deref_mut().println_mut();
    }
  }

  // static mut FATHER: Father = Father {
  //   child: Arc::new(Mutex::new(Son {
  //     value: Arc::new(Mutex::new(1)),
  //     value2: Arc::new(2),
  //   })),
  // };

  #[test]
  fn test() {}
}

mod test3 {
  use std::sync::{Arc, Mutex};
  struct SSS {
    value: Option<i32>,
  }
  static SSSSSS: SSS = SSS { value: Some(2) };
}

mod test4 {
  use std::sync::{Arc, Mutex};

  #[derive(Debug)]
  enum Values {
    None,
    Some(Arc<i32>),
  }
  #[derive(Debug)]
  pub struct Test4 {
    value: Values,
  }
  impl Test4 {
    pub fn println_test(&self) {
      println!("{:?}", self);
    }
  }

  static TEST4: Test4 = Test4 {
    value: Values::None,
  };
  // println!("{}", TEST4);
  #[test]
  fn test() {
    let test4 = Test4 {
      value: Values::None,
    };
    test4.println_test();
  }

  #[test]
  fn test2() {
    TEST4.println_test();
    // static  mut TEST44: Test4 = Test4 {
    //   value: Values::Some(Arc::new(3)),
    // };
  }
}
